import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;


public class VendingMachineItemTest {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	// The name is valid and the price is valid (>0).
	@Test
	public void testVendingMachineItem_Case1() {
		VendingMachineItem snickers = new VendingMachineItem("snickers", 1.25);
		
		assertEquals( "snickers", snickers.getName() );
		assertEquals( 1.25, snickers.getPrice(), 0.0001 );
	}	

	// The name is valid and the price is valid (=0).
	@Test
	public void testVendingMachineItem_Case2() {
		VendingMachineItem snickers = new VendingMachineItem("snickers", 0.00);
		
		assertEquals( "snickers", snickers.getName() );
		assertEquals( 0.00, snickers.getPrice(), 0.0001 );
	}
	

	// The name is invalid (empty) and the price is valid (>0).
	@Test
	public void testVendingMachineItem_Case3() {
		VendingMachineItem emptyItem = new VendingMachineItem(" ", 1.25);
		
		assertEquals( " ", emptyItem.getName() );
		assertEquals( 1.25, emptyItem.getPrice(), 0.0001 );
	}
	
	// The name is invalid (empty) and the price is valid (=0).
	@Test
	public void testVendingMachineItem_Case4() {
		VendingMachineItem emptyItem = new VendingMachineItem(" ", 0.00);
		
		assertEquals( " ", emptyItem.getName() );
		assertEquals( 0.00, emptyItem.getPrice(), 0.0001 );
	}
	
	// The name is invalid (null) and the price is valid (>0).
	@Test
	public void testVendingMachineItem_Case5() {
		VendingMachineItem nullItem = new VendingMachineItem(null, 1.25);
		
		assertEquals( null, nullItem.getName() );
		assertEquals( 1.25, nullItem.getPrice(), 0.0001 );
	}
	
	// The name is invalid (null) and the price is valid (=0).
	@Test
	public void testVendingMachineItem_Case6() {
		VendingMachineItem nullItem = new VendingMachineItem(null, 0.00);
		
		assertEquals( null, nullItem.getName() );
		assertEquals( 0.00, nullItem.getPrice(), 0.0001 );
	}
	
	// Valid name
	@Test
	public void testGetName_Case1() {
		VendingMachineItem snickers = new VendingMachineItem("snickers", 1.25);
		
		assertEquals( "snickers", snickers.getName() );
	}

	// Empty name
	@Test
	public void testGetName_Case2() {
		VendingMachineItem emptyItem = new VendingMachineItem(" ", 1.25);
		
		assertEquals( " ", emptyItem.getName() );
	}
	
	// Null name
	@Test
	public void testGetName_Case3() {
		VendingMachineItem nullItem = new VendingMachineItem(null, 1.25);
		
		assertEquals( null, nullItem.getName() );
	}
	
	// Price is >0.
	@Test
	public void testGetPrice_Case1() {
		VendingMachineItem snickers = new VendingMachineItem("snickers", 1.25);
		
		assertEquals( 1.25, snickers.getPrice(), 0.0001 );
	}
	
	// Price is =0.
	@Test
	public void testGetPrice_Case2() {
		VendingMachineItem snickers = new VendingMachineItem("snickers", 0.00);
		
		assertEquals( 0.00, snickers.getPrice(), 0.0001 );
	}
}
